package com.photography.mapper;

import com.photography.entity.Order;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;


public interface OrderMapper extends BaseMapper<Order> {
    /**
     * 根据ID查询订单
     */
    Order findById(@Param("orderId") Integer orderId);

    List<Order> findPage(Order order);
    @Select("SELECT * FROM orders WHERE user_id = #{userId} AND order_status = '待支付' ORDER BY order_create_time DESC")
    List<Order> findRelatedOrders(Integer userId);

    List<Order> findByUserId(@Param("userId") Integer userId);

    /**
     * 获取最近30天产品分类销售分布
     * @return 分类销售分布列表
     */
    List<Map<String, Object>> getCategoryDistribution();

    /**
     * 获取今日统计数据
     * @return 今日统计数据
     */
    Map<String, Object> getTodayStatistics();
}
